import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/layout',
    redirect: '/layout/home', // 马上重定向二级路由
    component: () => import('@/views/Layout'),
    children: [
      {
        path: 'home',
        component: () => import('@/views/Home'),
        meta: {   // 路由元信息：给当前路由对象配饰数据
          title: '首页'
        }
      },
      {
        path: 'search',
        component: () => import('@/views/Search'),
        meta: {
          title: '搜索'
        }
      }
    ]
  },
  {
    path: '/play',
    component: () => import('@/views/Play')
  },
  {
    path: '/comment',
    component: () => import('@/views/Comment')
  }
]

const router = new VueRouter({
  routes
})

export default router
